package cn.dengta.webapp.user.vo;

import java.util.Map;

import cn.dengta.common.model.State;
import cn.dengta.webapp.base.vo.AbstractVO;
import cn.dengta.webapp.user.entity.Favorite;
import cn.dengta.webapp.user.model.AssocType;
import lombok.Getter;
import lombok.Setter;
import me.codeplayer.util.X;

@Getter
@Setter
public class CollectionVO extends AbstractVO<Favorite> {

	/** 关联类型 */
	protected transient String assocType;
	/** 关联对象ID */
	protected Long assocId;
	/** 业务状态 */
	protected Integer status;
	/** 操作用户ID */
	protected Map<String, Object> user;
	/** 显示状态 */
	protected State state;
	public Object assocs;

	public static CollectionVO from(Favorite source) {
		return copy(source, CollectionVO::new);
	}

	public static CollectionVO fromFront(Favorite source) {
		return copy(source, CollectionVO::new, "status", "state");
	}

	private AssocType getAssocTypeE() {
		return AssocType.of(assocType);
	}

	public String getAssocType_() {
		return X.map(getAssocTypeE(), AssocType::getLabel);
	}

	public String getStatus_() {
		return status == 1 ? "已关注" : "取消关注";
	}

	public Integer getState() {
		return super.stateOutput(state);
	}

	public String getState_() {
		return super.getState_(state);
	}

}
